package gatperdut.chato.core.item;

import gatperdut.chato.constants.CSConstantsFood;
import gatperdut.chato.model.Chato.Constant.Fluid;
import gatperdut.chato.model.Chato.Item.Drink;

public class DrinkController extends FoodController {

    public DrinkController( Drink drink ) {
        super( drink );
    }

    public boolean containsThisFluid( Fluid fluid ) {
        return getAmount().getFluidContent() == fluid;
    }

    @Override
    public Drink getAmount() {
        return (Drink) super.getAmount();
    }

    public Fluid getFluidContent() {
        return getAmount().getFluidContent();
    }

    public void setFluidContent( Fluid fluid ) {
        getAmount().setFluidContent( fluid );
    }

    public boolean isSetWithEmptyContainerOnTop() {
        return hasNoPortionLeft() && getCurrent() > 1;
    }

    public int computeWeight() {
        float portion = getPortion();
        if ( portion == 0 ) {
            return 0;
        }
        int density = CSConstantsFood.getFluidDensity( getFluidContent() );
        int wholePart = ( getCurrent() - 1 ) * getAmount().getMaxPortion() * density;
        int portionPart = (int) ( portion * (float) density );
        return wholePart + portionPart;
    }
}
